package com.fireXXX.job.analysis.crawler.boss.progress;

import com.fireXXX.job.analysis.crawler.boss.constant.CityTypeEnum;
import com.fireXXX.job.analysis.crawler.boss.constant.EmployeeNumberTypeEnum;
import com.fireXXX.job.analysis.crawler.boss.constant.IndustryTypeEnum;
import com.fireXXX.job.analysis.crawler.boss.constant.PublicStepTypeEnum;
import lombok.Data;

@Data
public class CompanyProgress {
    private CityTypeEnum city;
    private IndustryTypeEnum industry;
    private PublicStepTypeEnum publicStep;
    private EmployeeNumberTypeEnum employeeNumber;
    private int page;

    public CompanyProgress(CityTypeEnum city, IndustryTypeEnum industry, PublicStepTypeEnum publicStep, EmployeeNumberTypeEnum employeeNumber, int page) {
        this.city = city;
        this.industry = industry;
        this.publicStep = publicStep;
        this.employeeNumber = employeeNumber;
        this.page = page;
    }

    public boolean next() {
        page = 1;
        if (employeeNumber.hasNext()) {
            employeeNumber = employeeNumber.next();
            return true;
        }

        if (publicStep.hasNext()) {
            publicStep = publicStep.next();
            employeeNumber = employeeNumber.first();
            return true;
        }

        if (industry.hasNext()) {
            industry = industry.next();
            publicStep = publicStep.first();
            employeeNumber = employeeNumber.first();
            return true;
        }

        if (city.hasNext()) {
            city = city.next();
            industry = industry.first();
            publicStep = publicStep.first();
            employeeNumber = employeeNumber.first();
            return true;
        }

        return false;
    }
}
